<template>
  <div
    class="menu-module"
    :style="{
      background,
      'flex-direction': ['left', 'top-left', 'bottom-left'].includes(position) ? 'row' : ''
    }"
    @click="$emit('click')"
  >
    <div class="menu-module__icon" :class="[`menu-module__icon--${position}`]">
      <slot>
        <img :src="icon" alt="" />
      </slot>
    </div>
    <div class="menu-module__content">
      <div class="menu-module__name">{{ name }}</div>
      <div class="menu-module__sub">{{ subName }}</div>
    </div>
  </div>
</template>

<script>
  export default {
    props: {
      name: {
        type: String,
        default: ''
      },
      subName: {
        type: String,
        default: ''
      },
      icon: {
        type: String,
        default: ''
      },
      position: {
        type: String,
        default: 'right'
      },
      background: {
        type: String,
        default: ''
      }
    }
  };
</script>

<style scoped lang="less">
  .menu-module {
    display: flex;
    flex-direction: row-reverse;
    height: 80px;
    margin-left: 15px;
    background-color: #fbfbfb;

    &:first-child {
      margin-left: 0;
    }

    &__content {
      display: flex;
      flex-direction: column;
      justify-content: center;
      width: calc(100% - 55px);
      padding: 20px 12px;
    }

    &__icon[class*='--left'] + &__content {
      width: calc(100% - 52px);
    }

    &__name {
      font-size: 17px;
      font-weight: 500;
      line-height: 20px;
      color: #171719;
    }

    &__sub {
      margin-top: 5px;
      font-size: 11px;
      line-height: 15px;
      color: #b3c5cf;
    }

    &__icon {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 55px;
      padding: 20px 12px 20px 0;

      &[class*='--left'] {
        width: 52px;
        padding: 20px 0 20px 12px;
      }

      &--top-right,
      &--top-left {
        align-items: flex-start;
        padding: 0;
      }

      &--bottom-right,
      &--bottom-left {
        align-items: flex-end;
        padding: 0;
      }

      img {
        display: inline-block;
        max-width: 100%;
        max-height: 100%;
        vertical-align: middle;
        object-fit: contain;
      }
    }
  }
</style>
